package com.hj.security.receiver;

import com.hj.security.service.UpdateWidgetService;

import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;

public class ProcessWidget extends AppWidgetProvider {

	private Intent intent;
	/**
	 * AppWidget的实例第一次被创建时调用
	 */
	@Override
	public void onEnabled(Context context) {
		super.onEnabled(context);
		//开启服务
		intent = new Intent(context, UpdateWidgetService.class);
		context.startService(intent);
	}
	/**
	 * 删除一个AppWidget时调用
	 */
	@Override
	public void onDeleted(Context context, int[] appWidgetIds) {
		super.onDeleted(context, appWidgetIds);
		//停止服务
		intent = new Intent(context, UpdateWidgetService.class);
		context.stopService(intent);
	}
	/**
	 * 最后一个appWidget被删除时调用
	 */
	@Override
	public void onDisabled(Context context) {
		// TODO Auto-generated method stub
		super.onDisabled(context);
	}
	/**
	 * 接受广播事件
	 */
	@Override
	public void onReceive(Context context, Intent intent) {
		// TODO Auto-generated method stub
		super.onReceive(context, intent);
	}
	/**
	 * 到达指定的更新时间或者当用户向桌面添加AppWidget时被调用
	 */
	@Override
	public void onUpdate(Context context, AppWidgetManager appWidgetManager,
			int[] appWidgetIds) {
		// TODO Auto-generated method stub
		super.onUpdate(context, appWidgetManager, appWidgetIds);
	}
}
